package com.hongxun.modules.csg.service.impl;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.hongxun.modules.csg.dao.CScheduleReportDao;
import com.hongxun.modules.csg.entity.CScheduleReportEntity;
import com.hongxun.modules.csg.service.CScheduleReportService;



@Service("cScheduleReportService")
public class CScheduleReportServiceImpl implements CScheduleReportService {
	@Autowired
	private CScheduleReportDao cScheduleReportDao;
	
	@Override
	public CScheduleReportEntity queryObject(String guid){
		return cScheduleReportDao.queryObject(guid);
	}
	
	@Override
	public List<CScheduleReportEntity> queryList(Map<String, Object> map){
		return cScheduleReportDao.queryList(map);
	}

	@Override
	public int queryTotal(Map<String, Object> map){
		return cScheduleReportDao.queryTotal(map);
	}
	
	@Override
	public void save(CScheduleReportEntity cScheduleReport){
        if(cScheduleReport.getGuid()==null||cScheduleReport.getGuid().equals("")) {

		    cScheduleReport.setGuid(UUID.randomUUID().toString());
        }
		cScheduleReportDao.save(cScheduleReport);
	}
	
	@Override
	public void update(CScheduleReportEntity cScheduleReport){
		cScheduleReportDao.update(cScheduleReport);
	}
	
	@Override
	public void delete(String guid){
		cScheduleReportDao.delete(guid);
	}
	
	@Override
	public void deleteBatch(String[] guids){
		cScheduleReportDao.deleteBatch(guids);
	}

	@Override
	public void insertOrReplaceOrDelete(List<CScheduleReportEntity> entities) {
		for (CScheduleReportEntity d : entities) {
			if (d.getSRDatastate().equals("删除")) {
				cScheduleReportDao.delete(d.getGuid());
			} else {
				CScheduleReportEntity cScheduleReportEntity = cScheduleReportDao.queryObject(d.getGuid());
				if (cScheduleReportEntity == null) {
					cScheduleReportDao.save(d);
				} else {
					cScheduleReportDao.update(d);
				}
			}
		}
	}


	@Override
	public List<CScheduleReportEntity> queryListToUpdatetime(Map<String, Object> map){
		return cScheduleReportDao.queryListToUpdatetime(map);
	}


	@Override
	public List<CScheduleReportEntity> queryListToExport(Map<String, Object> map){
		return cScheduleReportDao.queryListToExport(map);
	}

}
